import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:xianyu_school/xianyuApp/entity/goods/goods.dart';
import 'package:xianyu_school/xianyuApp/home/goodsdetail.dart';

class FHHomeGoodItem extends StatelessWidget {

  FHHomeGoodItem({Key key,this.model}) : super(key: key);
  final goods model;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      child: Card(
        child: Row(children: [
          Container(
            margin: EdgeInsets.all(5.0),
            child: Image.memory(
              base64.decode(model.img.split(";")[0]),
              fit: BoxFit.fill,
              gaplessPlayback:true,
              height: 110,
              width: 110,
            ),
          ),
          Container(
              height: 130,
              width: 200,
              alignment: Alignment.topLeft,
              child: ListView(
                children: [
                  Text(
                    model.goodsname,
                    style: TextStyle(
                        color: Colors.blue,
                        fontSize: 15,
                        height: 1.2,
                        fontFamily: "Courier",
                        decorationStyle: TextDecorationStyle.dashed
                    ),
                  ),
                  Text(
                    //"        三星Galaxy S21采用6.2英寸柔性直屏，分辨率为2400×1080像素，搭载了第二代动态AMOLED屏幕，支持48-120Hz的自适应刷新率。配合高通骁龙888处理器以及护眼模式，不管是在强光户外用手机追剧，还是在暗光室内用手机玩游戏，无论屏幕亮度是高是低，色彩显示更鲜艳自然，画面显示更清晰，操控体验更加迅速流畅，日常娱乐体验更爽快。",
                    model.description,
                    maxLines: 3,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                      fontSize: 13,
                    ),
                  ),
                  Text(
                    "￥"+model.price.toString(),
                    style: TextStyle(
                        color: Colors.red
                    ),
                  )
                ],
              )
          ),
        ],
        ),
      ),
      onTap: (){
        Navigator.push(context, MaterialPageRoute(builder: (_) {
          return goodsdetail(g:model);
        }));
      },
    );;
  }
}